package org.kl.auditsupervision.service.fnd;

 

import java.util.List;

import org.apache.commons.lang3.StringUtils;
import org.kl.auditsupervision.entity.fnd.SjjcPj;
import org.kl.auditsupervision.repository.fnd.SjjcPjDao;
import org.kl.bf.service.BasicService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.RequestParam;
import org.springside.modules.utils.Collections3;

import com.alibaba.fastjson.JSON;
/**
 * 审计监察评价
 */
// Spring Bean的标识.
@Component
// 默认将类中的所有public函数纳入事务管理.
@Transactional
public class SjjcPjService extends BasicService<SjjcPj> {
	@Autowired
	private SjjcPjDao sjjcPjDao;
	
	public List<SjjcPj> findByAuditProDtlId(String auditProDtlId){
		return sjjcPjDao.findByAuditProDtlId(auditProDtlId);
	}
	
	public void save(SjjcPj entity, @RequestParam(value = "inserted") String detailInserted,
			@RequestParam(value = "updated") String detailUpdated, @RequestParam(value = "deleted") String detailDeleted) {
		sjjcPjDao.save(entity);
		if (StringUtils.isNotBlank(detailInserted)) {
			List<SjjcPj> inserts = JSON.parseArray(detailInserted, SjjcPj.class);
			if (Collections3.isNotEmpty(inserts)) {
				for (SjjcPj a : inserts) {
					// 增加与主表相关的数据复制代码
					sjjcPjDao.save(a);
				}
			}
		}
		if (StringUtils.isNotBlank(detailUpdated)) {
			List<SjjcPj> updates = JSON.parseArray(detailUpdated, SjjcPj.class);
			if (Collections3.isNotEmpty(updates)) {
				for (SjjcPj b : updates) {
					sjjcPjDao.save(b);
				}
			}
		}
		if (StringUtils.isNotBlank(detailDeleted)) {
			List<SjjcPj> deletes = JSON.parseArray(detailDeleted, SjjcPj.class);
			if (Collections3.isNotEmpty(deletes)) {
				sjjcPjDao.delete(deletes);
			}
		}
	}
}
